1 Effect of UPSTM-Based Decorrelation on Feature Discovery

1.0.1 Loading the libraries

library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)

op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)

1.1 Material and Methods

About Dataset This dataset is a copy of another Kaggle dataset which can be accessed here: https://www.kaggle.com/c/glioma-radiomics The difference is that I have provided ground truth for the test set (test_GT.csv).

The suffix “omics” in Medical Science is associated with analysis of big sets of features (e.g. Genomics, Proteomics). Radiomics are imaging features (e.g., first order and second order) extracted from Regions of Interest (ROI) in radiology images based on predefined functions and filters. Low grade gliomas (LGG) are a type of brain tumors. Astrocytes and Oligodendrocytes which are two types of brain cells, are considered as origins of LGG. Adult LGG are characterized by different mutations which is important to be correctly identified. With this dataset the goal is to determine if an ROI has 1p19q codeletion (Mutacion=1) or not(Mutacion=0). This plays a key role in predicting patient’s response to chemotherapy and their survival. The dataset provides 640 different radiomics features for each ROI. There are 105 ROIs in the training set and 45 ROIs in the test cohort.

1.2 The Data

https://www.kaggle.com/datasets/knamdar/radiomics-for-lgg-dataset?select=test_GT.csv


LGG_Data <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/train.csv")
LGG_DataTest <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test.csv")
LGG_TestGT <- read.csv("~/GitHub/LatentBiomarkers/Data/LGG/test_GT.csv")
LGG_DataTest$Mutacion <- LGG_TestGT$Mutacion

LGG_Data <- rbind(LGG_Data,LGG_DataTest)

rownames(LGG_Data) <- LGG_Data$patientID
LGG_Data$patientID <- NULL

pander::pander(table(LGG_Data$Mutacion))
0 1
54 96

1.2.0.1 Standarize the names for the reporting

studyName <- "LGG"
dataframe <- LGG_Data
outcome <- "Mutacion"

TopVariables <- 10

thro <- 0.80
cexheat = 0.15

1.3 Generaring the report

1.3.1 Libraries

Some libraries

library(psych)
library(whitening)
library("vioplot")

1.3.2 Data specs

pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
rows col
150 640
pander::pander(table(dataframe[,outcome]))
0 1
54 96

varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]

largeSet <- length(varlist) > 1500

1.3.3 Scaling the data

Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns


  ### Some global cleaning
  sdiszero <- apply(dataframe,2,sd) > 1.0e-16
  dataframe <- dataframe[,sdiszero]

  varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
  tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
  dataframe <- dataframe[,tokeep]

  varlist <- colnames(dataframe)
  varlist <- varlist[varlist != outcome]


dataframe <- FRESAScale(dataframe,method="OrderLogit")$scaledData

1.4 The heatmap of the data


if (!largeSet)
{
  
  hm <- heatMaps(data=dataframe,
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 xlab="Feature",
                 ylab="Sample",
                 srtCol=45,
                 srtRow=45,
                 cexCol=cexheat,
                 cexRow=cexheat
                 )
  par(op)
}

1.4.0.1 Correlation Matrix of the Data

The heat map of the data


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  #cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
  cormat <- cor(dataframe[,varlist],method="pearson")
  cormat[is.na(cormat)] <- 0
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
  #                  scale = "row",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Original Correlation",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="Pearson Correlation",
                    xlab="Feature", ylab="Feature")
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.999999

1.5 The decorrelation


DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#> 
#>  Included: 633 , Uni p: 0.02929148 , Uncorrelated Base: 39 , Outcome-Driven Size: 0 , Base Size: 39 
#> 
#> 
 1 <R=1.000,r=0.975,N=  399>, Top: 85( 6 )[ 1 : 85 Fa= 81 : 0.975 ]( 81 , 245 , 0 ),<|>Tot Used: 326 , Added: 245 , Zero Std: 0 , Max Cor: 1.000
#> 
 2 <R=1.000,r=0.975,N=  399>, Top: 42( 3 )[ 1 : 42 Fa= 123 : 0.975 ]( 42 , 93 , 81 ),<|>Tot Used: 379 , Added: 93 , Zero Std: 0 , Max Cor: 1.000
#> 
 3 <R=1.000,r=0.975,N=  399>, Top: 6( 1 )[ 1 : 6 Fa= 129 : 0.975 ]( 6 , 7 , 123 ),<|>Tot Used: 379 , Added: 7 , Zero Std: 0 , Max Cor: 0.975
#> 
 4 <R=0.975,r=0.937,N=  207>, Top: 66( 2 )[ 1 : 66 Fa= 152 : 0.937 ]( 63 , 97 , 129 ),<|>Tot Used: 444 , Added: 97 , Zero Std: 0 , Max Cor: 0.999
#> 
 5 <R=0.999,r=0.949,N=  207>, Top: 11( 1 )[ 1 : 11 Fa= 155 : 0.949 ]( 11 , 13 , 152 ),<|>Tot Used: 449 , Added: 13 , Zero Std: 0 , Max Cor: 0.946
#> 
 6 <R=0.946,r=0.873,N=  213>, Top: 70( 1 )[ 1 : 70 Fa= 185 : 0.873 ]( 69 , 99 , 155 ),<|>Tot Used: 513 , Added: 99 , Zero Std: 0 , Max Cor: 0.936
#> 
 7 <R=0.936,r=0.868,N=  213>, Top: 32( 1 )[ 1 : 32 Fa= 194 : 0.868 ]( 31 , 38 , 185 ),<|>Tot Used: 534 , Added: 38 , Zero Std: 0 , Max Cor: 0.905
#> 
 8 <R=0.905,r=0.853,N=  213>, Top: 24( 1 )[ 1 : 24 Fa= 206 : 0.853 ]( 24 , 26 , 194 ),<|>Tot Used: 544 , Added: 26 , Zero Std: 0 , Max Cor: 0.996
#> 
 9 <R=0.996,r=0.898,N=  213>, Top: 3( 1 )[ 1 : 3 Fa= 207 : 0.898 ]( 3 , 3 , 206 ),<|>Tot Used: 544 , Added: 3 , Zero Std: 0 , Max Cor: 0.922
#> 
 10 <R=0.922,r=0.811,N=  150>, Top: 53( 1 )[ 1 : 53 Fa= 228 : 0.811 ]( 51 , 69 , 207 ),<|>Tot Used: 567 , Added: 69 , Zero Std: 0 , Max Cor: 0.993
#> 
 11 <R=0.993,r=0.847,N=  150>, Top: 9( 1 )[ 1 : 9 Fa= 229 : 0.847 ]( 9 , 10 , 228 ),<|>Tot Used: 567 , Added: 10 , Zero Std: 0 , Max Cor: 0.840
#> 
 12 <R=0.840,r=0.800,N=   54>, Top: 22( 2 )[ 1 : 22 Fa= 232 : 0.800 ]( 22 , 29 , 229 ),<|>Tot Used: 574 , Added: 29 , Zero Std: 0 , Max Cor: 0.999
#> 
 13 <R=0.999,r=0.800,N=   54>, Top: 4( 1 )[ 1 : 4 Fa= 233 : 0.800 ]( 4 , 4 , 232 ),<|>Tot Used: 574 , Added: 4 , Zero Std: 0 , Max Cor: 0.885
#> 
 14 <R=0.885,r=0.800,N=    2>, Top: 1( 1 )[ 1 : 1 Fa= 233 : 0.800 ]( 1 , 1 , 233 ),<|>Tot Used: 574 , Added: 1 , Zero Std: 0 , Max Cor: 0.799
#> 
 15 <R=0.799,r=0.800,N=    0>
#> 
 [ 15 ], 0.7988219 Decor Dimension: 574 Nused: 574 . Cor to Base: 231 , ABase: 20 , Outcome Base: 0 
#> 
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]

pander::pander(sum(apply(dataframe[,varlist],2,var)))

810

pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))

194

pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))

4.91

pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))

3.4

1.5.1 The decorrelation matrix


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  
  UPSTM <- attr(DEdataframe,"UPSTM")
  
  gplots::heatmap.2(1.0*(abs(UPSTM)>0),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Decorrelation matrix",
                    cexRow = cexheat,
                    cexCol = cexheat,
                   srtCol=45,
                   srtRow=45,
                    key.title=NA,
                    key.xlab="|Beta|>0",
                    xlab="Output Feature", ylab="Input Feature")
  
  par(op)
}

1.6 The heatmap of the decorrelated data

if (!largeSet)
{

  hm <- heatMaps(data=DEdataframe,
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 cexRow = cexheat,
                 cexCol = cexheat,
                 srtCol=45,
                 srtRow=45,
                 xlab="Feature",
                 ylab="Sample")
  par(op)
}

1.7 The correlation matrix after decorrelation

if (!largeSet)
{

  cormat <- cor(DEdataframe[,varlistc],method="pearson")
  cormat[is.na(cormat)] <- 0
  
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Correlation after IDeA",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="Pearson Correlation",
                    xlab="Feature", ylab="Feature")
  
  par(op)
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.7988219

1.8 U-MAP Visualization of features

1.8.1 The UMAP based on LASSO on Raw Data

classes <- unique(dataframe[,outcome])
raincolors <- rainbow(length(classes))
names(raincolors) <- classes
datasetframe.umap = umap(scale(dataframe[,varlist]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
text(datasetframe.umap$layout,labels=dataframe[,outcome],col=raincolors[dataframe[,outcome]+1])

1.8.2 The decorralted UMAP


datasetframe.umap = umap(scale(DEdataframe[,varlistc]),n_components=2)
plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After IDeA",t='n')
text(datasetframe.umap$layout,labels=DEdataframe[,outcome],col=raincolors[DEdataframe[,outcome]+1])

1.9 Univariate Analysis

1.9.1 Univariate



univarRAW <- uniRankVar(varlist,
               paste(outcome,"~1"),
               outcome,
               dataframe,
               rankingTest="AUC")

100 : wavelet.HHH_firstorder_10Percentile 200 : wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 : wavelet.HLL_gldm_GrayLevelVariance 500 : wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis




univarDe <- uniRankVar(varlistc,
               paste(outcome,"~1"),
               outcome,
               DEdataframe,
               rankingTest="AUC",
               )

100 : La_wavelet.HHH_firstorder_10Percentile 200 : La_wavelet.HHL_firstorder_Uniformity 300 : wavelet.HLH_glcm_Imc1 400 : La_wavelet.HLL_gldm_GrayLevelVariance 500 : La_wavelet.LHH_glrlm_LongRunLowGrayLevelEmphasis
600 : La_wavelet.LHL_glszm_LargeAreaHighGrayLevelEmphasis

1.9.2 Final Table


univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")

##topfive
topvar <- c(1:length(varlist)) <= TopVariables
pander::pander(univarRAW$orderframe[topvar,univariate_columns])
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
original_firstorder_Skewness 0.34095 0.841 -0.679 0.99 0.840 0.780
original_glcm_ClusterShade 0.38451 1.104 -0.841 1.42 0.509 0.755
wavelet.HLL_glcm_ClusterShade -0.47639 1.307 0.884 1.72 0.538 0.737
wavelet.HLL_firstorder_Skewness -0.30857 0.904 0.509 1.10 0.534 0.736
original_firstorder_Median -0.22280 0.858 0.598 1.10 0.981 0.732
original_glcm_MaximumProbability -0.11040 0.790 0.936 1.41 0.154 0.722
original_gldm_LargeDependenceHighGrayLevelEmphasis -0.00634 0.714 0.912 1.31 0.562 0.711
original_glcm_JointEnergy -0.02333 0.797 0.863 1.34 0.405 0.710
original_firstorder_Mean -0.17862 0.883 0.519 1.06 0.949 0.702
original_glszm_LargeAreaHighGrayLevelEmphasis 0.21656 1.113 1.284 1.60 0.196 0.700


topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]

theLaVar <- rownames(finalTable)[str_detect(rownames(finalTable),"La_")]

pander::pander(univarDe$orderframe[topLAvar,univariate_columns])
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
original_firstorder_Skewness 0.340947 0.8406 -0.67881 0.9905 0.83988 0.780
La_wavelet.HLL_glszm_SmallAreaHighGrayLevelEmphasis -0.024844 0.0265 0.01033 0.0430 0.24742 0.763
La_wavelet.HHL_glszm_GrayLevelNonUniformity 0.189965 0.6816 -0.22297 0.3396 0.73775 0.761
original_glcm_ClusterShade 0.384511 1.1037 -0.84057 1.4157 0.50941 0.755
La_wavelet.LHL_glcm_SumSquares -0.004027 0.3550 0.30007 0.3833 0.79236 0.754
La_original_gldm_GrayLevelNonUniformity -0.000621 0.0313 0.04464 0.0671 0.00279 0.749
La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -0.045862 0.1153 0.06854 0.1609 0.13121 0.748
La_wavelet.LHL_glrlm_RunLengthNonUniformity 0.095176 0.2746 -0.16389 0.2880 0.09992 0.741
La_wavelet.HLL_glrlm_HighGrayLevelRunEmphasis 0.007045 0.0147 -0.00944 0.0256 0.15151 0.737
wavelet.HLL_glcm_ClusterShade -0.476394 1.3069 0.88439 1.7240 0.53805 0.737

dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")

theSigDc <- dc[theLaVar]
names(theSigDc) <- NULL
theSigDc <- unique(names(unlist(theSigDc)))


theFormulas <- dc[rownames(finalTable)]
deFromula <- character(length(theFormulas))
names(deFromula) <- rownames(finalTable)

pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
mean total fraction
2.48 524 0.828


allSigvars <- names(dc)



dx <- names(deFromula)[1]
for (dx in names(deFromula))
{
  coef <- theFormulas[[dx]]
  cname <- names(theFormulas[[dx]])
  names(cname) <- cname
  for (cf in names(coef))
  {
    if (cf != dx)
    {
      if (coef[cf]>0)
      {
        deFromula[dx] <- paste(deFromula[dx],
                               sprintf("+ %5.3f*%s",coef[cf],cname[cf]))
      }
      else
      {
        deFromula[dx] <- paste(deFromula[dx],
                               sprintf("%5.3f*%s",coef[cf],cname[cf]))
      }
    }
  }
}

finalTable <- rbind(finalTable,univarRAW$orderframe[theSigDc[!(theSigDc %in% rownames(finalTable))],univariate_columns])


orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- deFromula[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]

Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")

finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
  DecorFormula caseMean caseStd controlMean controlStd controlKSP ROCAUC RAWAUC fscores
original_firstorder_Skewness 0.340947 0.8406 -0.67881 0.9905 0.83988 0.780 0.780 NA
La_wavelet.HLL_glszm_SmallAreaHighGrayLevelEmphasis -0.268wavelet.HLL_gldm_SmallDependenceHighGrayLevelEmphasis -0.740wavelet.HLL_glszm_HighGrayLevelZoneEmphasis + 1.000*wavelet.HLL_glszm_SmallAreaHighGrayLevelEmphasis -0.024844 0.0265 0.01033 0.0430 0.24742 0.763 0.517 -2
La_wavelet.HHL_glszm_GrayLevelNonUniformity -0.828original_firstorder_Energy + 1.000wavelet.HHL_glszm_GrayLevelNonUniformity 0.189965 0.6816 -0.22297 0.3396 0.73775 0.761 0.605 -1
original_glcm_ClusterShade 0.384511 1.1037 -0.84057 1.4157 0.50941 0.755 0.755 NA
La_wavelet.LHL_glcm_SumSquares -1.040wavelet.LHL_glcm_DifferenceAverage + 1.000wavelet.LHL_glcm_SumSquares -0.004027 0.3550 0.30007 0.3833 0.79236 0.754 0.505 5
La_original_gldm_GrayLevelNonUniformity + 1.000original_gldm_GrayLevelNonUniformity -0.994original_glrlm_GrayLevelNonUniformity -0.000621 0.0313 0.04464 0.0671 0.00279 0.749 0.493 -1
La_wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -1.066wavelet.HLL_firstorder_InterquartileRange + 1.000wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation -0.045862 0.1153 0.06854 0.1609 0.13121 0.748 0.511 -1
La_wavelet.LHL_glrlm_RunLengthNonUniformity -0.938original_firstorder_Energy + 1.000wavelet.LHL_glrlm_RunLengthNonUniformity 0.095176 0.2746 -0.16389 0.2880 0.09992 0.741 0.567 14
La_wavelet.HLL_glrlm_HighGrayLevelRunEmphasis + 1.000wavelet.HLL_glrlm_HighGrayLevelRunEmphasis -1.011wavelet.HLL_glszm_HighGrayLevelZoneEmphasis 0.007045 0.0147 -0.00944 0.0256 0.15151 0.737 0.504 2
wavelet.HLL_glcm_ClusterShade -0.476394 1.3069 0.88439 1.7240 0.53805 0.737 0.737 NA
wavelet.HHL_glszm_GrayLevelNonUniformity NA 0.413483 1.1592 0.07044 1.0597 0.03335 0.605 0.605 NA
wavelet.LHL_glrlm_RunLengthNonUniformity NA 0.348437 1.1018 0.16855 1.1564 0.03057 0.567 0.567 NA
wavelet.LHL_glcm_DifferenceAverage NA 0.166577 0.9383 0.00935 1.1651 0.40001 0.562 0.562 NA
wavelet.HLL_firstorder_InterquartileRange NA 0.198194 0.8825 0.05217 1.1175 0.93350 0.543 0.543 NA
wavelet.HLL_glszm_SmallAreaHighGrayLevelEmphasis NA 0.229794 0.9799 0.34473 1.1213 0.14187 0.517 0.517 NA
wavelet.HLL_firstorder_RobustMeanAbsoluteDeviation NA 0.165458 0.9506 0.12417 1.2083 0.99377 0.511 0.511 NA
wavelet.HLL_glszm_HighGrayLevelZoneEmphasis NA 0.240722 0.9642 0.32542 1.0827 0.23259 0.511 0.511 11
wavelet.LHL_glcm_SumSquares NA 0.169160 1.0239 0.30979 1.3158 0.17279 0.505 0.505 NA
wavelet.HLL_glrlm_HighGrayLevelRunEmphasis NA 0.250344 0.9771 0.31946 1.0915 0.22983 0.504 0.504 NA
original_firstorder_Energy NA 0.269887 1.0936 0.35427 1.2522 0.11884 0.499 0.499 8
wavelet.HLL_gldm_SmallDependenceHighGrayLevelEmphasis NA 0.285973 1.0350 0.34986 1.1809 0.23591 0.496 0.496 NA
original_gldm_GrayLevelNonUniformity NA 0.352015 1.1203 0.45162 1.3030 0.00371 0.493 0.493 NA
original_glrlm_GrayLevelNonUniformity NA 0.354630 1.1374 0.40928 1.2923 0.00129 0.486 0.486 NA